import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import * as path from "path";

// element-plus自动按需导入
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
//项目自适应
import pxtorem from "postcss-pxtorem";

export default defineConfig({
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },
  plugins: [
    vue(),
    AutoImport({
      imports: ["vue", "vue-router", "pinia"],
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  css: {
    postcss: {
      plugins: [pxtorem({ rootValue: 19.2, propList: ["*"] })],
    },
  },
  server: {
    // proxy: {
    //   //这个路径为http://192.168.1.182:3000/douyu/wgapi/vod/front/vodrank/getTagVideos
    //   "/douyu": {
    //     //target是代理的目标路径
    //     target: 'http://192.168.110.15:8000',
    //     changeOrigin: true, //必须要开启跨域
    //     //pathRewrite重写请求的路径,实际请求的路径没有代理标识douyu,需要把斗鱼重置为空字符串
    //     rewrite: (path) => path.replace(/\/douyu/, ""), // 路径重写
    //   },
    // },
    host: "0.0.0.0",
  },
});
